within ThreeD_MBS_Dynamics.Examples.Snakeboard;

model Rod_1
  extends RigidBodyEnergized;
  parameter SI.Acceleration[3] Gravity;
  parameter SI.Length L;
  parameter SI.Length Wp;
  parameter SI.Radius r2;
  // Relationship between Vertical and Horizontal Length of Rod_1
  parameter Real coef;
  VisualShape RodH(
    r0={0,0,-L/2},
    Shape="cylinder",
    LengthDirection={0,0,1},
    WidthDirection={1,0,0},
    Length=L,
    Width=2*r2,
    Height=2*r2,
    Material={0.5,0.5,1,0.5});
  VisualShape RodV(
    r0={0,0,0},
    Shape="cylinder",
    LengthDirection={0,1,0},
    WidthDirection={1,0,0},
    Length=L*coef,
    Width=2*r2,
    Height=2*r2,
    Material={0.5,0.5,1,0.5});
  VisualShape Platforma(
    r0={0,L*coef,-L/2 - 0.1},
    Shape="box",
    LengthDirection={0,0,1},
    WidthDirection={1,0,0},
    Length=L + 0.2,
    Width=Wp,
    Height=0.1,
    Material={0.5,0.5,1,0.5});
  WrenchPort InPortJointA annotation (extent=[-60, 80; -40, 100]);
  WrenchPort InPortJointB annotation (extent=[40, 80; 60, 100]);
  annotation (Diagram);
  WrenchPort InPortJoint annotation (extent=[-10, 80; 10, 100]);
equation
  RodH.S = T;
  RodH.r = r;
  RodV.S = T;
  RodV.r = r;
  Platforma.S = T;
  Platforma.r = r;
  F = m*Gravity + InPortJointA.F + InPortJointB.F + InPortJoint.F;
  M = InPortJointA.M + InPortJointB.M + InPortJoint.M + cross(InPortJointA.P
     - r, InPortJointA.F) + cross(InPortJointB.P - r, InPortJointB.F) + cross(
    InPortJoint.P - r, InPortJoint.F);
end Rod_1;
